<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class UserProject extends Model
{
    protected  $table='user_project';

    protected $fillable = [
        'user_id',
        'project_id',
        'team_id',
        'org_id',
        'reward_time',
        'content',
        'attachment',
        'verify_status',
        'verify_msg'
    ];

    public function project() {
        return $this->belongsTo('App\Models\Project', 'project_id', 'id');
    }


    public function user() {
        return $this->belongsTo('App\User', 'user_id', 'id');
    }

    public function plusTime($time) {
        if (!$this->id) {
            return false;
        }

        $this->fill([
            'reward_time' => $this->reward_time + $time
        ]);

        return $this->save();
    }
}
